package com.xq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xq.dao.TbDepartmentDao;
import com.xq.entity.TbDepartment;
import com.xq.service.TbDepartmentService;
import com.xq.vo.TbDepShowVo;
import com.xq.vo.TbDepVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbDepartment)表服务实现类
 *
 * @author makejava
 * @since 2020-07-25 20:23:47
 */
@Service("tbDepartmentService")
public class TbDepartmentServiceImpl extends ServiceImpl<TbDepartmentDao, TbDepartment> implements TbDepartmentService {
    @Resource
    TbDepartmentDao departmentDao;
    @Override
    public List<TbDepVo> findByDepartmentCount() {
        return departmentDao.findByDepartmentCount();
    }

    /**
     * 部门管理页面的展示+查询
     * @param current
     * @param size
     * @return
     */
    @Override
    public Page<TbDepShowVo> findPageByDep(Integer current,Integer size,String name) {
        Page<TbDepartment> page=new Page<>(current,size);
        QueryWrapper<TbDepShowVo> wrapper=new QueryWrapper<>();
            if(!StringUtils.isEmpty(name)){
                wrapper.like("name",name);
            }
        Page<TbDepShowVo> pageByDep = departmentDao.findPageByDep(page, wrapper);
        return pageByDep;
    }
}